<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0px;
            margin: 0px;
        }

        body {
            width: 100%;
            height: 100%;
            padding-top: 10vw;
        }
        span {
            color: white;
            font-size: 3vw;
            display: inline-block;
    
        }

        .range-box {
            display: flex;
            margin: 0 auto;
            width: 80vw;
            height: 10vw;
            justify-content: space-around;
            align-items: center;
            border: 2px solid white;
            background-color: rgb(106, 106, 106);
            position: relative;
        }

        .whiteline {
            width: 2px;
            height: 6vw;
            position: absolute;
            background-color: rgb(255, 255, 255);
            left: 39.7vw;
            display: none;
        }

        .range {
            appearance: none;
            width: 60vw;
            height: 1vw;
            background-color: black;
            background: linear-gradient(90deg, black 20%, rgb(255, 0, 89), black 80%);
            background-repeat: no-repeat;
            border-radius: 2vw;
        }

        .range::-webkit-slider-thumb {
            appearance: none;
            width: 5vw;
            height: 5vw;
            border-radius: 50%;
            background-color: lightgrey;
        }

        .textcircle {
            width: 5vw;
            height: 5vw;
            line-height: 4.5vw;
            text-align: center;
            border-radius: 50%;
            font-size: 2vw;
            background-color: red;
            position: absolute;
            display: none;
        }
    </style>
</head>

<body>
    <div class="range-box">
        <span class="letters">L</span>
        <input type="range" class="range" max="20" min="0" value="10">
        <span class="letters">R</span>
        <div class="whiteline"></div>
        <div class="textcircle"></div>
    </div>
</body>
<script>
    const range = document.querySelector(".range");
    const whiteline = document.querySelector(".whiteline");
    const textcircle = document.querySelector(".textcircle");

    range.oninput = () => {
        textcircle.innerText = range.value
        if (range.value == 10) {
            whiteline.style.display = "none";
            textcircle.style.display = "none"
            range.style.background = "linear-gradient(90deg,black 20%,red, black 80%)"
        } else if (range.value > 10) {
            whiteline.style.display = "block";
            textcircle.style.display = "block";
            textcircle.style.left = `${60 * parseInt(range.value) / 20 - 3}vw`;
            textcircle.style.right = "auto";
            range.style.background = `linear-gradient(90deg,black 50%,lightgrey 50% ${parseInt(range.value) / 20 * 100}%, red ${parseInt(range.value) / 20 * 100}% ,black ${parseInt(range.value) / 20 * 100 + 20}% 100% )`
        } else {
            whiteline.style.display = "block";
            textcircle.style.display = "block";
            textcircle.style.left = "auto";
            textcircle.style.right = `${60 * (20 - parseInt(range.value)) / 20 - 3}vw`;
            range.style.background = `linear-gradient(-90deg,black 50%,lightgrey 50% ${(20 - parseInt(range.value)) / 20 * 100}%, red  ${(20 - parseInt(range.value)) / 20 * 100}%  ,black ${(20 - parseInt(range.value)) / 20 * 100 + 20}% 100%)`
        }
    }
</script>

</html>